#!/usr/bin/python

import AudioFile
import FeatureHandler
import features.Lpc
import features.Loudness
import features.SpectralSparsity
import matplotlib.pyplot as plt
import sys

def main():
    ahand = AudioFile.AudioFile(sys.argv[1])
    ahand.setOverlap(0.5)
    ahand.setFrameSize(1024)
    ahand.setPreEmphasis(1)
    frames = ahand.initFrames()
    lpc = features.Lpc.Build(4)
    loud = features.Loudness.Build()
    spec = features.SpectralSparsity.Build()
    feat = FeatureHandler.Build()
    feat.pushTimeFeatures(lpc)
    feat.pushTimeFeatures(loud)
    feat.pushSpecFeatures(spec)
    for i in range(0,frames):
        data = ahand.readFrame(i)
        feat.calcFeatures(data)
    plt.plot(lpc.getValues())
    plt.plot(loud.getValues())
    plt.plot(spec.getValues())
    plt.show()

if __name__ == '__main__':
    main()
